<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>TMBL_WORKTIME_PARENT</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript">
  $(document).ready(function(){
  	$("#arrangework").click(function(){
  		WdatePicker({onpicked:function(){
  			$("#arrangework").blur();
  			var da=$("#arrangework").val();
  			$.ajax({
  				url: "<%=path%>/workTableNO.do?getNo",
  				type:"post",
  				dataType:"json",
  				data:{da:da},
  				success: function(data){
  					$("#m").html(data.msg);
  					$("#no").val(data.msg);
  				}
  			});
  		},dateFmt:'yyyy-MM'});
  	});
  });
  function sub(){
	  
	  var rowsData = $('#selectPalce').datagrid('getSelections');
	  var arrangework=$("#arrangework").val();
	  if(arrangework==null || arrangework==""){
		  tip('请选择排班时间！');
		  return;
	  }
	  
		 if (!rowsData || rowsData.length==0) {
	        tip('<t:mutiLang langKey="common.please.select.edit.item"/>');
	        return;
		 }
		var ids='',names='';
		if(rowsData.length>0){
			  for(i=0;i<rowsData.length;i++){
			     var node = rowsData[i];
			     ids += node.id+',';
			    names += node.workplace+',';
			  }
			  $("#wId").val(ids);
			  $("#wName").val(names);
		}
		
		$.ajax({//检查是否有服务点重复
			url: "<%=path%>/tmblWorktimeParentController.do?checkDepart",
			type:"post",
			dataType:"json",
			data:{
				arrangework:arrangework,
				workPlaceId:ids
			},
			success: function(data){
				if(data.success){
					//保存
					
					return;
				}else{
					alert(data.msg);
					return;
				}
			}
		});
  }
  </script>
 </head>
 <body>
  <form id="s" action="tmblWorktimeParentController.do?doAdd"  method="post">
			<table cellpadding="0" cellspacing="1" class="formtable">
				<tr>
					<td align="right">
						<label class="Validform_label" style="font-size: 20px">
							班次名称:
						</label>
					</td>
					<td class="value">
					     	 <input id="arrangework" name="arrangework"  type="text" style="width: 150px" class="Wdate" /><span class="text" style="font-size: 20px">：排班表<span id="m" style="font-size: 20px"></span></span>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">班次名称</label>
					</td>
				</tr>
				
			</table>
			<input type="hidden" name="number" id="no">
			<input type="hidden" name="wId" id="wId">
			<input type="hidden" name="wName" id="wName">
	</form>
	
	
  <div class="easyui-layout" fit="true">
	  <div region="center" style="padding:0px;border:0px">
   <t:datagrid name="selectPalce" pagination='true' singleSelect="false" checkbox="true" fitColumns="false" title="服务点列表" actionUrl="tmblWorktimeParentController.do?selectDepart" idField="id" >
	   <t:dgCol title="ID"  field="id"  hidden="true"    width="120"></t:dgCol> 
	   <t:dgCol title="服务点名称"  field="workplace"    width="120"></t:dgCol>
  </t:datagrid>
  	  </div>
   <div><input type="hidden" id="sub" onclick="sub()"> </div>
 </div>

 	
 	
 </body>
 	
